/*! \file core_test.cpp
 *	\brief 
 *
 *	created:	2010/11/23
 *	created:	23:11:2010   18:32
 *	filename: 	C:\src\tactics-engine\libs\core\tests\core_test.cpp
 *	file path:	C:\src\tactics-engine\libs\core\tests
 *	file base:	core_test
 *	file ext:	cpp
 *	author:		Vitalii Trubchaninov
 *				vitalii.trubchaninov@ubisoft.com
 */

#include "core/tests/stdafx.h"

#include <algorithm>
#include <iostream>
#include <string>

#include "core/RBTree.h"

namespace tt{

void print(const core::Pair<std::string, int>& value)
{
	std::cout << value.first << std::endl;
}

} //namespace tt

TEST(test_rbtree, main)
{
	using namespace tt;

	typedef core::RBTree<std::string, int> Tree;

	Tree tree;

	{
		const char* strings[] = {"m", "d", "c", "b", "a", "w", "x", "y", "z", 0};
		const char** insert_string = strings;
		for (; *insert_string; ++insert_string)
		{
			tree.insert( Tree::value_type(*insert_string, 0) );
			EXPECT_TRUE( tree.sanityCheck() );
		}
	}

// 	std::for_each(tree.begin(), tree.end(), &print);
	{
		const char* strings[] = {"a", "b", "c", "d", "m", "w", "x", "y", "z"};
		const char** check_string = strings;
		Tree::iterator check_it = tree.begin();
		for (; check_it != tree.end(); ++check_it, ++check_string)
		{
			EXPECT_EQ( check_it->first, *check_string );
		}
	}
}